package com.caiden_micheal.dynamic.file_management.web;

import com.caiden_micheal.base.domain.AjxResult;
import com.caiden_micheal.dynamic.file_management.dto.DFileRemoveDTO;
import com.caiden_micheal.dynamic.file_management.service.FileManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/dFile")
public class FileManagementController {

    @Autowired
    private FileManagementService fileManagementService;

    @PostMapping("/dFileUpload")
    public AjxResult dFileUpload(@CookieValue(name = "Authorization") String token, @RequestParam("key") String fileName, @RequestParam("file") MultipartFile file) {
        return fileManagementService.fileUpload(token, fileName, file);
    }

    @PostMapping("/dFileRemove")
    public AjxResult dFileRemove(@RequestBody DFileRemoveDTO dFileRemoveDTO) {
        return fileManagementService.fileRemove(dFileRemoveDTO);
    }
}
